<template>
	<view class="guess-section">
		<view v-for="(item, index) in goodsList" :key="index" class="guess-item" @click="navToDetailPage(item.goods_id)">
			<view class="image-wrapper"><image :src="item.thumb_img" mode="aspectFill"></image></view>
			<text class="title clamp">{{item.goods_name}}</text>
			<text class="price">￥{{item.price}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsList:[]
			}
		},
		onLoad() {
			this.loadData();
		},
		methods: {
			async loadData() {
				var that = this
				this.$api.postUrl(this.$api._api.ApiIndexMsList, {}, function(res){
					let _data = {};
					if(typeof(res.data) == "object"){
						_data = res.data;
					}else{
						_data = JSON.parse(res.data);
					}
					if(_data.status == 1){
						that.goodsList = _data.data.goodsList
					}
				})
			},
			//详情页
			navToDetailPage:function(goods_id){
				uni.navigateTo({
					url: '/pages/category/product/product?id='+goods_id
				})
			}
		}
	}
</script>

<style lang="scss">
	.guess-section{
		margin-top:25rpx;
		padding: 0 20rpx;
		.guess-item{
			background: #fff;
			border-radius:10rpx;
			overflow: hidden;
			display:flex;
			flex-direction: column;
			padding-bottom: 30rpx;
			margin-bottom: 4%;
		}
		.image-wrapper{
			width: 100%;
			height: 330rpx;
			image{
				width: 100%;
				height: 100%;
				opacity: 1;
			}
		}
		.title{
			font-size:30rpx;
			color: $font-color-dark;
			line-height: 80rpx;
			padding: 0 20rpx;
		}
		.price{
			font-size:32rpx;
			color: $uni-color-primary;
			line-height: 1;
			padding: 0 20rpx;
			font-weight: bold;
		}
	}
</style>
